package com.toonyoo.eurekaproducer.services;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class HelloService {

    @Value("${server.port}")
    private String port;


    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping(value = "/sayHello")
    public String sayHello(String name){

        return "Hello " + name + "，I am from " + port;
    }

    @RequestMapping(value = "/testInsert")
    public String testInsert(String name, Integer age){
        return null;
    }

    @RequestMapping(value = "/testUpdate")
    public String testUpdate(Integer id, String name, Integer age){
        return null;
    }

    @RequestMapping(value = "/testRabbit")
    public String testRabbit(String message){
        rabbitTemplate.convertAndSend(message);
        return "rabbit success";
    }
}
